home *** CD-ROM | disk | FTP | other *** search
- #include "stdafx.h"
-
- #include <string.h>
-
- cBonus *bonus = 0, *bonus_belowscreen = 0, *bonus_abovescreen = 0;
-
- cBonus::cBonus(int _x, int _y, char *name)
- : cGameObject(cProperties::find_w_error("BONUS", name))
- {
- add((cList **)&bonus);
-
- set_sequence("MOVING", TRUE);
-
- set_position(_x, _y);
- }
-
- cGameObject *cBonus::make(int x, int y, cProperties *props)
- {
- if (eq(props->name, "MINE"))
- return new cBonusMine(x, y);
-
- if (eq(props->name, "SPREAD"))
- return new cBonusSpread(x, y);
-
- if (eq(props->name, "JETPACK"))
- return new cBonusJetpack(x, y);
-
- if (eq(props->name, "ROCKET"))
- return new cBonusRocket(x, y);
-
- if (eq(props->name, "THUMPER"))
- return new cBonusThumper(x, y);
-
- //if (eq(props->name, "HEALTH"))
- return new cBonusHealth(x, y);
- }
-
- int cBonus::control()
- {
- cGameObject::control();
-
- bounce_on_boundaries();
-
- // Check if we were hit
-
- if (explode)
- {
- new cEffect (x, y, orig, "EXPLODE");
-
- return FALSE;
- }
-
- // Check if we are to be picked up
-
- cCharacter *c = (cCharacter *)check_radial_boundaries(circle_bounds, players);
-
- if (c != 0)
- {
- pickup(c);
-
- new cEffect (x, y, orig, "PICKUP");
-
- return FALSE;
- }
-
- return !in_water();
- }
-
- void cBonus::pickup(cCharacter *)
- {
- }
-
- cBonusMine::cBonusMine(int _x, int _y) : cBonus(_x, _y, "MINE")
- {
- }
-
- void cBonusMine::pickup(cCharacter *c)
- {
- new cInventoryMine (&(c->weapon_down));
- }
-
- cBonusSpread::cBonusSpread(int _x, int _y) : cBonus(_x, _y, "SPREAD")
- {
- }
-
- void cBonusSpread::pickup(cCharacter *c)
- {
- new cInventorySpread (&(c->weapon));
- }
-
- cBonusJetpack::cBonusJetpack(int _x, int _y) : cBonus(_x, _y, "JETPACK")
- {
- }
-
- void cBonusJetpack::pickup(cCharacter *c)
- {
- c->jetpack_time += JETPACK_TIME;
- }
-
- cBonusRocket::cBonusRocket(int _x, int _y) : cBonus(_x, _y, "ROCKET")
- {
- }
-
- void cBonusRocket::pickup(cCharacter *c)
- {
- new cInventoryRocket (&(c->weapon));
- }
-
- cBonusThumper::cBonusThumper(int _x, int _y) : cBonus(_x, _y, "THUMPER")
- {
- }
-
- void cBonusThumper::pickup(cCharacter *c)
- {
- new cInventoryThumper (&(c->weapon_down));
- }
-
- cBonusHealth::cBonusHealth(int _x, int _y) : cBonus(_x, _y, "HEALTH")
- {
- }
-
- void cBonusHealth::pickup(cCharacter *c)
- {
- // Give extra armour
-
- c->armor += 34;
-
- // Display percentage above player
-
- c->set_text_above(construct("%d%%", c->armor <= 0? 0:c->armor), sec);
- }
-